const convertToDockerRunCommands = require('decomposerize');

const yargs = require('yargs');
const fs = require('fs');

const args = yargs
  .option('f', {
    alias: 'file',
    describe: 'Path to the Docker Compose input file',
    type: 'string',
    demandOption: true
  })
  .argv;

let dockerComposeInput;

if (args.file) {
  try {
    dockerComposeInput = fs.readFileSync(args.file, 'utf8');
  } catch (e) {
    console.error(`Error reading file: ${e}`);
    dockerComposeInput = `
version: '3'
services:
  myapp:
    image: myapp-image
`;
  }
}

const configuration = {
  command: 'docker run',
  rm: false,
  detach: false,
  multiline: false,
  'long-args': false,
  'arg-value-separator': ' ',
};

const dockerRunCommands = convertToDockerRunCommands(dockerComposeInput, configuration);

console.log('Generated Docker Run Commands:');
console.log(dockerRunCommands);